package com.newtouch.bxzs.enterprise.controller;

import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import com.newtouch.bxzs.enterprise.config.MyLog;
import com.newtouch.bxzs.enterprise.model.vo.UserRelationShipVO;
import com.newtouch.bxzs.enterprise.service.RelationShipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 三方关系Controller
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/14 16:05</td>
 * <td>Amour</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author Amour
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "三方关系")
@RestController
@RequestMapping("relationship")
@SuppressWarnings("unchecked")
public class UserRelationShipController {

    @Autowired
    private RelationShipService relationShipService;

    @ApiOperation("保存三方关系")
    @PostMapping("/saveRelationShip")
    @MyLog(systemFunctionName = "三方关系",systemFunctionUrl = "/relationship/saveRelationShip",userOperationType = 1,userOperationSummary = "保存三方关系")
    public BaseResponse<String> saveRelationShip(@RequestBody UserRelationShipVO userRelationShipVO){
        if (relationShipService.isExistRelationShip(userRelationShipVO)){
            return RespGenerator.returnOK("三方关系已存在");
        }else {
           relationShipService.saveRelationShip(userRelationShipVO);
            return RespGenerator.returnOK("三方关系创建成功");
        }
    }

}